<template>
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column type="selection" width="55"></el-table-column>
    <template v-for="item in tableList">
      <el-table-column
        :prop="item.prop"
        :label="item.label"
        :width="item.width"
      ></el-table-column>
    </template>

    <el-table-column label="创建时间">
      <template #default="scope">
        {{ dateFilter(scope.row.createAt) }}
      </template>
    </el-table-column>

    <el-table-column label="修改时间">
      <template #default="scope">
        {{ dateFilter(scope.row.updateAt) }}
      </template>
    </el-table-column>

    <el-table-column label="功能" width="140">
      <template #default="scope">
        <el-button size="small" @click="handleEdit(scope.row)">
          编辑
        </el-button>
        <el-button size="small" type="danger" @click="handleDelete(scope.row)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script setup>
import { dateFilter } from '@/utils/time'

const props = defineProps(['tableData', 'tableList'])
const emits = defineEmits(['handleEditEmit', 'handleDeleteEmit'])
const handleEdit = (page) => {
  emits('handleEditEmit', page)
}
const handleDelete = (page) => {
  emits('handleDeleteEmit', page)
}
</script>

<style lang="scss" scoped>
.edit {
  padding: 20px 0;
}
.form-pagination {
  text-align: center;
  padding: 20px 0;
}
</style>
